<?php
$params = array_merge(
    require __DIR__ . '/../../common/config/params.php',
    require __DIR__ . '/../../common/config/params-local.php',
    require __DIR__ . '/params.php',
    require __DIR__ . '/params-local.php'
);

return [
    'id'                  => 'app-api',
    'basePath'            => dirname(__DIR__),
    'controllerNamespace' => 'api\controllers',
    'bootstrap'           => ['log'],
    'modules'             => [],
    'components'          => [
        'request'      => [
            'csrfParam' => '_csrf-api',
        ],
        'user'         => [
            'identityClass'   => 'api\models\Adminuser',
            'enableAutoLogin' => true,
            'enableSession'   => false,
            'loginUrl' => null,
            //'identityCookie' => ['name' => '_identity-api', 'httpOnly' => true],
        ],
//        'session'      => [
//            // this is the name of the session cookie used for login on the api
//            'name' => 'advanced-api',
//        ],
        'log'          => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets'    => [
                [
                    'class'  => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
        'urlManager'   => [
            'enablePrettyUrl'     => true,
            'enableStrictParsing' => true,
            'showScriptName'      => false,
            'rules'               => [
                [
                    'class'         => 'yii\rest\UrlRule',
                    'controller'    => ['post'],
                    'extraPatterns' => [
                        'GET search' => 'search'
                    ],
                ],
                [
                    'class'      => 'yii\rest\UrlRule',
                    'controller' => ['top10'],
                    'pluralize'  => false,
                ],
                [
                    'class'         => 'yii\rest\UrlRule',
                    'controller'    => ['auth'],
                    'except' => ['index','update','view','delete'],
                    'pluralize'  => false,
                    'extraPatterns' => [
                        'POST login' => 'login'
                    ],
                ],
            ],
        ],
    ],
    'params'              => $params,
];
